#!/bin/sh
branch="master" 
trap exit ERR
rm -rf _tmp
git clone git://github.com/mavlink/mavlink.git -b $branch _tmp
rm -rf _tmp/.git
rsync -av _tmp/message_definitions/v1.0/* ./message_definitions_v1.0/
rm -rf include_v1.0
WD=`pwd`
OUT_DIR="$WD/include_v1.0"
IN_FILE="$WD/message_definitions_v1.0/ardupilotmega.xml"
CMD="./_tmp/pymavlink/generator/mavgen.py --lang=C -o $OUT_DIR $IN_FILE"
$CMD
rm -rf _tmp
